package net.yiny.scrummer.ui.storyboard

import groovy.mock.interceptor.MockFor
import javax.swing.JPanel
import net.yiny.scrummer.model.PhaseStrip
import static org.hamcrest.MatcherAssert.assertThat
import static org.hamcrest.Matchers.is


PhaseStripController controller
def mockBuilder
def mockPhaseStrip

before_each '', {
    controller = new PhaseStripController()
    mockBuilder = new MockFor(PhaseStripBuilder)
    mockPhaseStrip = new MockFor(PhaseStrip)
}

scenario 'initialising the controller', {
    JPanel panel = new JPanel()
    mockBuilder.demand.initialise {panel}
    given 'a controller with a builder set to it', {
        controller.builder = mockBuilder.proxyInstance()
    }
    when 'the controller is initialised'
    then 'it should return the panel from the builder', {
        assertThat controller.initialise(), is(panel)
    }
    and 'should have called the builder\'s initialisation', {
        mockBuilder.verify controller.builder
    }
}

scenario 'setting the builder to the controller', {
    def builder
    given 'a builder object', {
        builder = mockBuilder.proxyInstance()
    }
    when 'the builder is set on the controller', {
        controller.builder = builder
    }
    then 'the controller should store that same one', {
        assertThat controller.builder, is(builder)
    }
}
